﻿define([], function(){
    var tpl = {};
    tpl.init1 = function(){
        var html = '';
        html += basicInfo();
        return html;
    };
    tpl.init2 = function(){
        var html = '';
        html += temperament();
        return html;
    };
    tpl.init3 = function(){
        var html = '';
        html += subject();
        return html;
    };
    tpl.init4 = function(){
        var html = '';
        html += resultInfo();
        return html;
    };
    tpl.init5 = function(){
        var html = '';
        html += resultTable();
        return html;
    };
    tpl.init6 = function(){
        var html = '';
        html += history();
        return html;
    };
    tpl.init7 = function(){
        var html = '';
        html += guides();
        return html;
    };
    tpl.dialog = function(){
        var html = '';
        html += dialog();
        return html;
    };
    var basicInfo = function(){
        return '<script type = "text/html" id="basicInfo-tpl">'+
                    '<li>姓名：{{userName}}</li>'+
                    '<li>年龄：{{monthAge}}</li>'+
                    '<li>测试日期：{{testDate}}</li>'+
                '</script>'
    };
    var temperament = function(){
        return '<script type = "text/html" id="temperament-tpl">'+
                    '{{each data as value,i}}'+
                        '<ul class="clearfix ques-item {{if !value.showFlag}} ques-hide {{/if}} {{if i==0}} ques-checked {{/if}}" value = "{{value.value}}" id = "{{value.id}}">'+
                            '<li>{{value.index}}</li>'+
                            '<li>{{value.ques}}</li>'+
                        '</ul>'+
                    '{{/each}}'+
                '</script>'
    };
    var subject = function(){
        return '<script type = "text/html" id="subject-tpl">'+
            '{{each data as value,i}}'+
            '<li class="{{if i==0}} checking {{/if}}" quesId = "{{value.id}}" value = "{{value.value}}">{{value.index}}</li>'+
            '{{/each}}'+
            '</script>'
    };
    var resultInfo = function(){
        return '<script type = "text/html" id="resultInfo-tpl">'+
                    '<div>基本<br/>信息</div>'+
                    '<div class="clearfix">'+
                        '<span>孩子姓名：{{userName}}</span>'+
                        '<span>性别：{{if gender == "N"}}男{{else}}女{{/if}}</span>'+
                        '<span>年龄：{{testAge}}</span>'+
                        '<span>评估医生：{{doctorName}}</span>'+
                    '</div>'+
            '</script>'
    };
    var resultTable = function(){
        return '<script type = "text/html" id="resultTable-tpl">'+
                    '<tr>'+
                        '<td>得分</td>'+
                        '<td>{{activityLevelScore}}</td>'+
                        '<td>{{rhythmicScore}}</td>'+
                        '<td>{{dodgeScore}}</td>'+
                        '<td>{{adaptiveScore}}</td>'+
                        '<td>{{intensityReactionScore}}</td>'+
                        '<td>{{moodScore}}</td>'+
                        '<td>{{persistenceScore}}</td>'+
                        '<td>{{attentionScatteredScore}}</td>'+
                        '<td>{{reactionThresholdScore}}</td>'+
                    '</tr>'+
                    /*'<tr>'+
                        '<td>标准差</td>'+
                        '<td>{{activityLevelAverage}}</td>'+
                        '<td>{{rhythmicAverage}}</td>'+
                        '<td>{{dodgeAverage}}</td>'+
                        '<td>{{adaptiveAverage}}</td>'+
                        '<td>{{intensityReactionAverage}}</td>'+
                        '<td>{{moodAverage}}</td>'+
                        '<td>{{persistenceAverage}}</td>'+
                        '<td>{{attentionScatteredAverage}}</td>'+
                        '<td>{{reactionThresholdAverage}}</td>'+
                    '</tr>'+*/
                    '<tr>'+
                        '<td>判定</td>'+
                        '<td colspan="9" class={{if type == "难养型" }} "bg-red" {{else if type == "易养型" }} "bg-green" {{else}} "bg-yellow" {{/if}}>{{type}}</td>'+
                    '</tr>'+
                '</script>'
    };
    var guides =  function(){
        return '<script type = "text/html" id="guides-tpl">'+
                '{{each data as value}}'+
                    '{{if value.title}}'+
                        ' <div>'+
                            '<p class="number-title"><span class="right"></span>{{value.title}}</p>'+
                            '<ul>'+
                            '{{each value.lists as list}}'+
                                '<li>{{list.item}}</li>'+
                            '{{/each}}'+
                            '</ul>'+
                        '</div>'+
                    '{{else}}'+
                        ' <div>'+
                            '{{each value.lists as list,i}}'+
                            '{{if i == 0}}'+
                                '<p class="number-title"><span class="right"></span>{{list.item}}</p>'+
                            '{{else}}'+
                                '<p>{{list.item}}</p>'+
                            '{{/if}}'+
                            '{{/each}}'+
                        '</div>'+
                    '{{/if}}'+
                '{{/each}}'+
                '</script>'
    };
    var history = function(){
        return '<script type = "text/html" id="history-tpl">'+
                    '{{each data as value}}'+
                    '<li answerId = "{{value.answerId}}"><span class="right"></span>{{value.testTime}}({{value.testAge}})</li>'+
                    '{{/each}}'+
                '</script>'
    };

    /*
     * 弹窗模板
     * */
    var dialog = function(){
        return '<script type = "text/html" id="dialog-tpl">'+
                    '<div class="modal fade" tabindex="-1" role="dialog" id="myModal">'+
                    '<div class="modal-dialog" role="document">'+
                    '<div class="modal-content">'+
                    '<div class="modal-header">'+
                    '<h4 class="modal-title">{{title}}</h4>'+
                    '</div>'+
                    '<div class="modal-body">{{tips}}</div>'+
                    '<div class="modal-footer">'+
                    '<button type="button" class="btn btn-info" data-dismiss="modal" flag = "1">{{btn1}}</button>'+
                    '<button type="button" class="btn btn-info" data-dismiss="modal" flag = "0">{{btn0}}</button>'+
                    '</div>'+
                    '</div>'+
                    '</div>'+
                    '</div>'+
                '</script>'
    };
    return tpl;
});